<?php
/**
 * Created by PhpStorm.
 * User: zhang
 * Date: 2018/4/17
 * Time: 12:39
 */
namespace app\common\model;

use think\Controller;

class Base extends Controller{
    //public $check;
    //public $mysql;
    public $jwt;
    protected $token;

    function __construct(){
        
        /*if(!$this->isMD5Verify()){
            echo echoJson(0, "数据验证失败!");
        }*/
//        header("Access-Control-Allow-Origin: http://a.com");
//        header("Access-Control-Allow-Origin: *");
//        header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept,X-TOKEN");

        //$this->check = new Check();
        //$this->mysql = new Mysql();
        $this->jwt = new Jwt_base();

        $this->token = $_SERVER["HTTP_X_TOKEN"];

        if(empty($this->token)){
            echoJson(0, "token无效,请登录使用");
        }else if($this->token !== "none")
            $this->jwt->decode($this->token);
    }

    function token($uid,$username){
        return $this->jwt->encode($uid,$username);
    }

}